package com.toprs.business.controller

import com.toprs.base.result.Result
import com.toprs.business.entity.ApplicationBase
import com.toprs.business.entity.StatisticEntity
import com.toprs.business.service.StatisticService
import com.toprs.business.vo.StatisticVO
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.servlet.http.HttpServletResponse
import org.springframework.web.bind.annotation.*


@RequestMapping("/statistic")
@RestController
@Tag(description = "统计模块", name = "统计模块")
class StatisticController(val statisticService: StatisticService) {


    @PostMapping("/by-dept")
    @Operation(summary = "按部门统计")
    fun statisticByDept(@RequestBody statisticVO: StatisticVO): Result<List<StatisticEntity>> {
        return Result.success(statisticService.statisticByDept(statisticVO))
    }

    @PostMapping("/by-month")
    @Operation(summary = "按月份统计")
    fun statisticByMonth(@RequestBody statisticVO: StatisticVO): Result<List<StatisticEntity>> {
        return Result.success(statisticService.statisticByMonth(statisticVO))
    }

    @PostMapping("/export-excel/{type}")
    @Operation(summary = "导出excel")
    fun exportExcel(
        @RequestBody statisticVO: StatisticVO,
        @Schema(description = "类型： 0 按部门  1 按月") @PathVariable type: Int,
        response: HttpServletResponse

    ) {

        statisticService.exportExcel(statisticVO, type, response)
//        return Result.success(statisticService.statisticByMonth(statisticVO))
    }


}